﻿//----------------------------------------------
// Flip Web Apps: Game Framework
// Copyright © 2016 Flip Web Apps / Mark Hewitt
//
// Please direct any bugs/comments/suggestions to http://www.flipwebapps.com
// 
// The copyright owner grants to the end user a non-exclusive, worldwide, and perpetual license to this Asset
// to integrate only as incorporated and embedded components of electronic games and interactive media and 
// distribute such electronic game and interactive media. End user may modify Assets. End user may otherwise 
// not reproduce, distribute, sublicense, rent, lease or lend the Assets. It is emphasized that the end 
// user shall not be entitled to distribute or transfer in any way (including, without, limitation by way of 
// sublicense) the Assets in any other way than as integrated components of electronic games and interactive media. 

// The above copyright notice and this permission notice must not be removed from any files.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//----------------------------------------------

using GameFramework.UI.Dialogs.Components;
using UnityEditor;

namespace GameFramework.UI.Dialogs.Editor
{
    [CustomEditor(typeof(GameOver))]
    public class GameOverEditor : UnityEditor.Editor
    {
        //GameItem _gameItem;
        SerializedProperty _localisationBaseProperty;
        SerializedProperty _timesPlayedBeforeRatingPromptProperty;
        SerializedProperty _showStarsProperty;
        SerializedProperty _showTimeProperty;
        SerializedProperty _showCoinsProperty;
        SerializedProperty _showScoreProperty;
        SerializedProperty _continueSceneProperty;
        SerializedProperty _updatePlayerScoreProperty;
        SerializedProperty _updatePlayerCoinsProperty;
        SerializedProperty _periodicUpdateDelayProperty;
        SerializedProperty _pauseWhenShownProperty;
        SerializedProperty _timeScaleProperty;
        SerializedProperty _resetTimeScaleProperty;

        protected virtual void OnEnable()
        {
            // get serialized objects so we can use attached property drawers (e.g. tooltips, ...)
            _localisationBaseProperty = serializedObject.FindProperty("LocalisationBase");
            _timesPlayedBeforeRatingPromptProperty = serializedObject.FindProperty("TimesPlayedBeforeRatingPrompt");
            _showStarsProperty = serializedObject.FindProperty("ShowStars");
            _showTimeProperty = serializedObject.FindProperty("ShowTime");
            _showCoinsProperty = serializedObject.FindProperty("ShowCoins");
            _showScoreProperty = serializedObject.FindProperty("ShowScore");
            _continueSceneProperty = serializedObject.FindProperty("ContinueScene");
            _updatePlayerScoreProperty = serializedObject.FindProperty("UpdatePlayerScore");
            _updatePlayerCoinsProperty = serializedObject.FindProperty("UpdatePlayerCoins");
            _pauseWhenShownProperty = serializedObject.FindProperty("_pauseWhenShown");
            _timeScaleProperty = serializedObject.FindProperty("_timeScale");
            _resetTimeScaleProperty = serializedObject.FindProperty("_resetTimeScale");
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(_localisationBaseProperty);
            EditorGUILayout.PropertyField(_timesPlayedBeforeRatingPromptProperty);
            EditorGUILayout.PropertyField(_showStarsProperty);
            EditorGUILayout.PropertyField(_showTimeProperty);
            EditorGUILayout.PropertyField(_showCoinsProperty);
            EditorGUILayout.PropertyField(_showScoreProperty);
            EditorGUILayout.PropertyField(_continueSceneProperty);
            EditorGUILayout.PropertyField(_updatePlayerScoreProperty);
            EditorGUILayout.PropertyField(_updatePlayerCoinsProperty);
            EditorGUILayout.PropertyField(_pauseWhenShownProperty);
            if (_pauseWhenShownProperty.boolValue)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(_timeScaleProperty);
                EditorGUILayout.PropertyField(_resetTimeScaleProperty);
                EditorGUI.indentLevel--;
            }

            serializedObject.ApplyModifiedProperties();
        }
    }
}
